//
//  VisitorViewController.swift
//  MicroBlog
//
//  Created by  NorthCity on 15/11/4.
//  Copyright © 2015年  NorthCity. All rights reserved.
//

import UIKit

class VisitorViewController: UITableViewController {
//    MARK: - 外部访问属性
//    访客视图
    var visitorView : VisitorView?
//    用户登录访问标示
 private var userLogin = UserAccountViewModel.sharedUserAccount.userLogin
//    MARK: -  外部访问方法
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func loadView() {
        userLogin ? super.loadView():setUpVisitorView()
    }
//    MARK: - 私有属性
//    MARK: - 私有方法
///   设置访客视图
    private func setUpVisitorView (){
    
        visitorView = VisitorView()
        view = visitorView
        
//   添加事件监听方法
        visitorView?.registerButton.addTarget(self, action: "visitorViewDidRegister", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "visitorViewDidLogin", forControlEvents: UIControlEvents.TouchUpInside)
//        设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidRegister")
        navigationItem.rightBarButtonItem =  UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidLogin")
        
    }
}
//MARK: - 事件监听方法
extension VisitorViewController{
 @objc private func visitorViewDidRegister(){
        print("注册")
    }
  @objc private  func visitorViewDidLogin(){
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
}



